{if $full_page}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>权限管理</title>
<link rel="stylesheet" href="Res/boot/css/bootstrap.min.css" type="text/css" media="screen" />
<link rel="stylesheet" href="Res/boot/css/bootstrap-theme.min.css" type="text/css" media="screen" />
<script type="text/javascript" src="Res/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="Res/js/jquery.cookie.js"></script>
<script type="text/javascript" src="Res/boot/js/bootstrap.min.js"></script>
<script type="text/javascript" src="Res/js/listTable.js"></script>
<link rel="stylesheet" href="Res/css/page.css" type="text/css" />
<link rel="stylesheet" href="Res/css/global.css" type="text/css" />
{literal}
<style>
    .listDiv{margin:0 auto;}  
    table tbody td span:hover{background-color:#00E8D7}
</style>
{/literal}
</head>
<body>
<div class="container-fluid">
	<div class="row-fluid">
            <div class="span12 panel panel-info">                
                <span class="cp_title">权限管理</span>
                <div class="add_cp">
                        <a href="index.php?c=action&m=create">+添加权限</a>
                </div>	
                <div class="panel-heading">
                    <label for="action_id">权限結構:</label>
                    <select id="action_id" name="action_id">
                        <option value="-1">請選擇</option>
                        <option value="0">父菜單</option>
                        {foreach from=$struct item=row}
                        {if $cookie.action_id == $row.action_id}
                            <option value="{$row.action_id}" selected="true">{$row.action_chinese}</option>
                        {else}
                            <option value="{$row.action_id}">{$row.action_chinese}</option>
                        {/if}
                            {foreach from=$row.child item=child}
                            {if $cookie.action_id == $child.action_id}
                                <option value="{$child.action_id}" selected="true">----------{$child.action_chinese}</option>
                            {else}
                                <option value="{$child.action_id}">----------{$child.action_chinese}</option>
                            {/if}                            
                            {/foreach}
                        {/foreach}
                    </select>
                    <label for="action_code">权限代码:</label>
                    <input class="input-medium search-query" id="action_code" name="action_code" type="text" placeholder="权限代码" />   
                    
                    <label for="action_url">權限名稱:</label>
                    <input class="input-medium search-query" id="action_chinese" name="action_chinese" type="text" placeholder="權限名稱" /> 
                    
                    <label for="action_url">URL:</label>
                    <input class="input-medium search-query" id="action_url" name="action_url" type="text" placeholder="URL" />   
                    
                    <button type="button" id="btn_search" class="btn btn-success">查找</button>                        
                </div>
 
                <div class="listDiv" id="listDiv">
{/if}
                <table id="data_table_id" class="table table-hover table-bordered">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th><a href="javascript:listTable.sort('action_id', 'DESC');" title="点击对列表排序">自增ID</a>{$sort_action_id}</th>
                        <th><a href="javascript:listTable.sort('parent_id', 'DESC');" title="点击对列表排序">父ID</a>{$sort_parent_id}</th>
                        <th>权限代码</th>
                        <th>权限URL</th>
                        <th>权限中文</th>
                        <th>菜单</th>
                        <th title="权重可设置范围0-255">
                            <a href="javascript:listTable.sort('weight', 'DESC');" title="点击对列表排序">权重</a>{$sort_weight}</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>    
                        {foreach from=$data.pageData item=row}
                        <tr>
                            <td>{$row.id}</td>
                            <td>{$row.action_id}</td>
                            <td>{$row.parent_id}</td>
                            <td><span onclick="listTable.edit(this, 'edit_fields', {$row.action_id}, 'action_code')" title="点击修改">{$row.action_code}</span></td>
                            <td><span onclick="listTable.edit(this, 'edit_fields', {$row.action_id}, 'action_url')" title="点击修改">{$row.action_url}</span></td>
                            <td><span onclick="listTable.edit(this, 'edit_fields', {$row.action_id}, 'action_chinese')" title="点击修改">{$row.action_chinese}</span></td>
                            <td style="text-align:center;">
                                <span class="glyphicon {$row.is_menu}" style="cursor:pointer;font-size: 16px;line-height: 28px;" onclick="listTable.toggle(this, {$row.action_id}, 'is_menu')"></span>
                            </td>
                            <td><span onclick="listTable.edit(this, 'edit_fields', {$row.action_id}, 'weight')" title="点击修改">{$row.weight}</span></td>
                            <td style="text-align:center;">   
                                <button type="button" class="btn btn-info" title="添加子类" onclick="addchild({$row.action_id})">
                                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                                </button>
                                <button type="button" class="btn btn-info" title="编辑" onclick="edit({$row.action_id})">
                                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                </button>
                                <button type="button" class="btn btn-info" title="删除" onclick="listTable.remove({$row.action_id})" aria-label="Left Align">
                                    <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                                </button>
                            </td>
                        </tr>
                        {/foreach}
                    </tbody>
                    <tfoot>
                        <!-- 分页数据 -->
                        <tr style="text-align:center;margin: 0 auto;">
                            <td colspan="8"><div class="iPageHtml">{$data.pageHtml}</div></td>
                        </tr>
                    </tfoot>
                </table>
{if $full_page}
                </div>
            </div>
	</div>
</div>
<div style="clear:both;"></div>
<script type="text/javascript">
//    listTable.c = 'action';
    listTable.m = 'query';
    listTable.id = 'listDiv';
    $("#btn_search").click(function(){
        listTable.filter['page'] =1;
        listTable.filter['action_id'] = $("#action_id").val();
        listTable.filter['action_code'] = $("#action_code").val();
        listTable.filter['action_url'] = $("#action_url").val();
        listTable.filter['action_chinese'] = $("#action_chinese").val();
        listTable.loadList();
    });
    function edit(id) {
        var url = "index.php?c=action&m=edit&id=" + id;
        window.location.href = url;
    }
    function addchild(id) {
        var url = "index.php?c=action&m=create&id=" + id;
        window.location.href = url;
    }
</script>
</body>
</html>
{/if}

